<?php
$objUser		= new Users(); 
$objCommon 		= new Vfriend_Common();

$strOption		= $objRequest->getParam('poption', '');
$strKey			= $objRequest->getParam('pkey', '');
$intGender		= $objRequest->getParam('pgender', 0);
$strCountry		= $objRequest->getParam('pcountry', '');
$intProvince	= $objRequest->getParam('pprovince', 0);
$intAfrom		= $objRequest->getParam('pafrom', 0);
$intAto			= $objRequest->getParam('pato', 0);
$intReligion	= $objRequest->getParam('preligion', 0);
$intEducation	= $objRequest->getParam('peducation', 0);
$intOccupation	= $objRequest->getParam('poccupation', 0);
$intPosition	= $objRequest->getParam('pposition', 0);
$strStart		= $objRequest->getParam('pstart', '');
$strEnd			= $objRequest->getParam('pend', '');
$intCancel		= $objRequest->getParam('pcancel', 0);
$intPage		= $objRequest->getParam('page', 1);
$intLimit		= ADMIN_LIMIT;
$intOff			= (($intPage-1) * $intLimit);
$intTotal		= 0;
if($strAction == 'waiting' && $strKey != '')  $strOption = 'email';
$arrResult		= $objUser->getAll(	$intStatus, $strOption, $strKey, $intGender, $strCountry, 
									$intProvince, $intAfrom, $intAto, $intReligion, $intEducation, 
									$intOccupation, $intPosition, $strStart, $strEnd, $intOff, $intLimit, $intTotal);

if($strOption != '' || $strKey != '' || $intGender > 0 || $strCountry != 'VN' || $intProvince > 0 || 
	$intAfrom > 0 || $intAto > 0 || $intReligion > 0 || $intEducation > 0 || $intOccupation > 0 
	|| $intPosition > 0 || $strStart != '' || $strEnd != '') {
	$strUrl	.= 'poption=' . $strOption . '&pkey=' . $strKey . '&pgender=' . $intGender . '&pcountry=' . $strCountry . 
				'&pprovince=' . $intProvince . '&pafrom=' . $intAfrom . '&pato=' . $intAto . '&preligion=' . $intReligion . 
				'&peducation=' . $intEducation . '&poccupation=' . $intOccupation . '&pposition=' . $intPosition . '&pstart=' . $strStart . '&pend=' . $strEnd . '&' ;
	$_SESSION['pcancel'] = 1;	
	$_SESSION['post']	 = $objRequest->getParams();
}
else {
	if(isset($_SESSION['post'])) unset($_SESSION['post']);
	if(isset($_SESSION['pcancel'])) unset($_SESSION['pcancel']);
}
if($intCancel == 1) {
	unset($_SESSION['pcancel']);
	unset($_SESSION['post']);	
}
# list
$this->view->arrResult		= $arrResult;
$this->view->intTotal		= $intTotal;
$this->view->intOffset		= $intOff;
$this->view->intLimit		= $intLimit;
$this->view->strUrl			= $strUrl;
# search
$this->view->arrGender 		= Vfriend_Function::gender();
$this->view->arrOption		= $arrOption;
$this->view->arrCountry		= $objCommon->getCountry();
$this->view->arrProvince	= $objCommon->getProvince(COUNTRY_DEFAULT);
$this->view->arrAge			= Vfriend_Function::arrayNumber(USER_AGE_FROM,USER_AGE_TO);
$this->view->arrReligion	= $objCommon->getReligion();
$this->view->arrEducation	= $objCommon->getEducation();
$this->view->arrOccupation	= $objCommon->getOccupation();
$this->view->arrPosition	= $objCommon->getPosition();
?>